home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
com_pkg3.zip
/
COM_PKG3.ASM
next >
Wrap
Assembly Source File
|
1986-06-01
|
42KB
|
1,056 lines
30-May-86 01:03:08-PDT,41855;000000000001
Return-Path: <milne@ICSE.UCI.EDU>
Received: FROM ICSE.UCI.EDU BY USC-ISIB.ARPA WITH TCP ; 30 May 86 00:57:05 PDT
Received: from localhost by ICSE.UCI.EDU id a007132; 29 May 86 22:54 PDT
To: info-ibmpc@usc-isib.arpa
Subject: ComPackage version for UCSD p-System
Date: Thu, 29 May 86 22:54:20 -0800
From: Alastair Milne <milne@ICSE.UCI.EDU>
Here is my adaptation of the simpler version of ComPackage for the UCSD
p-System. There are 5 or 6 separate source files, mostly because of
limitations of the p-System assembler. They are delimited by <<<<< marks.
I have placed on each file the documentation header we use at work, to
explain it and give its relations to the other files. I hope they will be
adequate: this is the first time I've sent them to a non-p-System
installation.
Several of the names exported to Pascal have been changed (lengthened).
This was done to make them clearer, and in particular to avoid confusion
with names from other units trying to serve the same purpose. I trust
it will not result in too much confusion.
The bug fix I reported is in the interrupt service routine, whose file is
still called COM.PKG1.TEXT.
I hope you will not find restoring this to MASM conventions overly
difficult. If questions arise about what I've done, I'll be happy to help.
Thank you,
Alastair Milne
<<<<<<<<<<<<<<<<<<<<<<<<<<<
;{% global equates and macro definitions for ComPackage
;File Name : COM.EQU.TEXT Code Name : <none>
;
;Assembly context.
; Files included : none
;
;%}
rsize .equ 2048 ; size of receive buffer
tsize .equ 256 ; size of transmit buffer
base .equ 3F0H ; base of address of aux. port registers
aux_int .equ 0CH ; interrupt number for aux port
int_off .equ aux_int*4 ; offset of interrupt vector
datreg .equ base + 8H ; data register
dll .equ base + 8H ; low divisor latcH
dlh .equ base + 9H ; high divisor latch
ier .equ base + 9H ; interrupt enable register
iir .equ base + 0AH ; interrupt identification register
lcr .equ base + 0BH ; line control register
mcr .equ base + 0CH ; modem control register
lsr .equ base + 0DH ; line status register
msr .equ base + 0EH ; modem status register
dla .equ 80H ; divisor latch access
mode .equ 03H ; 8-bits, no parity
dtr .equ 0BH ; bits to set dtr line
dtr_of .equ 00H ; turn off dtr, rts, and tHe interupt driver
thre .equ 20H ; mask to find status of xmit holding register
rxint .equ 01H ; enable data available interrupt
txint .equ 02H ; enable tx holding register empty interrupt
tcheck .equ 20H ; mask for checking tx reg status on interrupt
rcheck .equ 01H ; mask for checking rx reg status on interrupt
imr .equ 21H ; interuprt mask register
int_mask .equ 0EFH ; mask to clear bit 4
int_pend .equ 01H ; there is an interrupt pending
mstat .equ 00H ; modem status interrupt
wr .equ 02H ; ready to xmit data
rd .equ 04H ; received data interrupt
lstat .equ 06H ; line status interrupt
ack .equ 244 ; acknowledge symbol
parity .equ 7FH ; bits to mask off parity
ocw2 .equ 20H ; operational control word on 8259
eoi .equ 64H ; specific end of interrupt 4
brkbit .equ 40H ; bits to cause break
true .equ 1 ; truth
false .equ 0 ; falsehood
XOn .equ 17 ; ASCII Transmit On code, for XOn/XOff protocl
XOff .equ 19 ; ASCII Transmit Off code, " " "
; assumes the parameter is the first word of an IP:CS pair,
; places the current CS into the CS half, and does an
; indirect long call to the routine pointed to.
; NOTE: destroys bx
.macro CallRel
lea bx, cs:%1
mov cs:(bx+2), cs
calll cs:(%1)
.endm
<<<<<<<<<<<<<<<<<<<<<<<<<<<
.title "COM.PKG"
;{% interrupt handler, installer, and remover for ComPackage
;File Name : COM.PKG1.TEXT Code Name : COM.PKG1.CODE
;
;History:
; (Adapted from code for MS-Pascal by John Romkey and Jerry Saltzer of MIT
; by Richard Gillmann (GILLMANN@ISIB), 1983. Taken from COM_PKG1.ASM
; from the INFO-IBMPC repository at the University of Southern California.)
;Date Coder Modification
; winter, 1986 Alastair Milne Adapted to p-System assembler syntax,
; and p-System calling conventions.
; - clearing of serial port (i.e. forced break)
; moved from init. of interrupt handler
; to user-callable routine.
; - XOn/XOff protocol (input & output) added to
; intrpt handler.
; - bug fix: transmit-ready interrupt is raised
; before transmit shift register is ready.
; Caused strings to be sent as garbage.
; Added loop to wait for the shift reg.
; before sending.
;
;Assembly context.
; Files included : COM.EQU.TEXT
;
;Linked to : COM.PKG.P.CODE to obtain : COM.PKG.CODE
;
;Important Additional Info:
; All this code expects to use serial port 1 on the IBM PC or compatibles.
; No allowance is made for machines with no serial port installed.
;
;%}
;
.include com.equ.text
;
; int_hndlr - handles interrupts generated by the remote serial port
;
.PROC int_hndlr ; *WARNING* - this routine MUST NOT be .REL
.def dataseg, ivecofst, int_segment, start_tdata, end_tdata, size_tdata
.def tdata, rdata, start_rdata, end_rdata, size_rdata
.def handleraddr
push bp
push ds
push es
push di
push ax
push bx
push cx
push dx
; set up data segment
mov ax,cs:dataseg
mov ds,ax
mov es,ax
; find out where interrupt came from and jump to routine to handle it
mov dx,iir
in al,dx
cmp al,rd
jz rcv_chk ; if it's from the receiver
cmp al,wr
jz tmit_chk ; if it's from the transmitter
cmp al,lstat
jz lstat_int ; interrupt becuase of line status
cmp al,mstat
jz mstat_int ; interrupt because of modem status
jmp int_end ; interrupt when no interrupt pending, go away
lstat_int:
mov dx,lsr ; clear interrupt
in al,dx
jmp repoll ; see if any more interrupts
mstat_int:
mov dx,msr ; clear interrupt
in al,dx
jmp repoll ; see if any more interrupts
tmit_chk:
mov dx,lsr
in al,dx
and al,tcheck
jz repoll ; transmitter not yet ready,
; so see if any more interrupts
.public SndSuspended
goodtx: test ss:SndSuspended, 1
jnz $1
cmp size_tdata,0 ; see if any more data to send
jne have_data ; if not equal then there is data to send
; if no data to send, or host sent XOff, then reset tx interrupt and return
$1 call StopWriting
jmp repoll
have_data:
TSRReadyFlag .equ 01000000T ; the LSR bit indicating the Transmitter